package com.csdj.springcloudt309.gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RouteConfig {

    @Bean
    public RouteLocator routeLocator(RouteLocatorBuilder builder){
        return builder.routes().route("test3",r -> {
            return r.path("/s").uri("https://www.baidu.com");
        })
                .route("test4",r -> {
                    return r.path("/map").uri("https://news.sina.com.cn");
                })
                .route("lb",r->{
                    return r.path("/order/**")
                            .filters(f->{
                                return f.addRequestHeader("uname","abcde");
                            })
                            .uri("lb://order");
                })
                .build();
    }
}
